/*
 * Copyright 2013 Sigurd Randoll <srandoll@digiway.de>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.digiway.rapidbreeze.server.model.storage;

import java.net.URL;
import java.util.List;

/**
 *
 * @author Sigurd Randoll <srandoll@digiway.de>
 */
public interface StorageProviderRepository {

    /**
     * Registers a new {@linkplain StorageProvider} which is represented by the
     * given name and {@linkplain StorageProviderDownloadClient} implementation and puts it
     * into the repository.
     *
     * @param name
     * @param storageDownloadClass
     * @throws IllegalArgumentException if the given name is already registered.
     */
    public StorageProvider registerProvider(String name, Class<? extends StorageProviderDownloadClient> storageDownloadClass);

    /**
     * Retrieves a list of all available {@linkplain StorageProvider}
     *
     * @return list, never empty
     */
    public List<StorageProvider> getStorageProviders();

    /**
     * Looks up a {@linkplain StorageProvider} instance which is able to handle
     * the given {@linkplain URL}.
     *
     * @param url
     * @return a {@linkplain StorageProvider} instance or null if there is no
     * storage provider which is able to handle the url.
     */
    public StorageProvider getStorageProvider(URL url);

    /**
     * Updates the given {@linkplain StorageProvider} in the repository.
     *
     * @param provider
     */
    public void updateStorageProvider(StorageProvider provider);

    /**
     * Clears the complete repository.
     */
    public void clearAll();
}
